import re

from .apps.demo.urls import urlpatterns as demo_urlpatterns
from .apps.api_ngx.urls import urlpatterns as api_ngx_urlpatterns


def include(base_path, _handlers):
    pattern = re.compile(r'/+')
    res_handlers = []
    for path, handler in _handlers:
        path = base_path + path
        path = pattern.sub('/', path)
        res_handlers.append((path, handler))
    return res_handlers


urlpatterns = [
    *include(r'/', api_ngx_urlpatterns),
    *include(r'/', demo_urlpatterns),
]
